import {
  getVehicleCategoryList,
  getVehicleInsuranceItemsList,
  getVehicleNaturesList,
} from "@/commonData";
import { FormOptions } from "@/components/SmForm/src/types/types";
import { searchOptionsResolve } from "@/components/SmForm/src/utils";
import { createInputList } from "@/utils/form";

export const useSearchForm = (handleQuery: any, queryParams: any) => {
  const vehicleCategoryList = getVehicleCategoryList();
  const vehicleNaturesList = getVehicleNaturesList();
  const vehicleInsuranceItemsList = getVehicleInsuranceItemsList();

  const list: any = createInputList([
    {
      type: "select",
      data: vehicleCategoryList,
      prop: "vehicleCategoryId",
      label: "车辆种类",
    },
    {
      prop: "vehicleNatureId",
      type: "select",
      data: vehicleNaturesList,
      label: "车辆性质",
    },

    {
      type: "select",
      data: vehicleInsuranceItemsList,
      prop: "vehicleInsuranceItemId",
      label: "统筹项目",
    },
  ]);
  const searchFormOptions = ref<Array<FormOptions>>(list);

  searchOptionsResolve(searchFormOptions, handleQuery);

  const getSearchFormData = () => {
    return queryParams;
  };
  return {
    searchFormOptions,
    getSearchFormData,
  };
};
